package com.dfec.water.dao;

import com.dfec.framework.mybatis.core.mapper.BaseMapperX;
import com.dfec.framework.mybatis.core.page.PageParam;
import com.dfec.framework.mybatis.core.page.PageUtils;
import com.dfec.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dfec.water.entity.YdbForecastEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;

/**
 * 预测信息Dao接口
 *
 * @author df
 * @date Thu Jan 23 10:24:59 CST 2025
 */
@Mapper
public interface YdbForecastDao extends BaseMapperX<YdbForecastEntity> {

    /**
     * description:分页查询
     *
     * @param pageParam 分页参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    default PageUtils selectPage(PageParam<YdbForecastEntity> pageParam) {
        YdbForecastEntity entity = pageParam.getEntity() == null ? new YdbForecastEntity() :pageParam.getEntity();
        return this.selectPage(pageParam, dealParams(entity));
    }


    /**
     * 不带分页查询
     * @param ydbForecastEntity
     * @return
     */
    default  List<YdbForecastEntity> selectAll(YdbForecastEntity ydbForecastEntity){
        return this.selectList(dealParams(ydbForecastEntity));
    }

    /**
     * description:查询条件拼接
     *
     * @param entity 参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    public default LambdaQueryWrapperX<YdbForecastEntity> dealParams(YdbForecastEntity entity){
        return new LambdaQueryWrapperX<YdbForecastEntity>()
                .likeIfPresent(YdbForecastEntity::getName, entity.getName())
                .eqIfPresent(YdbForecastEntity::getForecastDesc, entity.getForecastDesc())
                .eqIfPresent(YdbForecastEntity::getForecastJson, entity.getForecastJson())
                .eqIfPresent(YdbForecastEntity::getForecastAreaSize, entity.getForecastAreaSize())
                .eqIfPresent(YdbForecastEntity::getBoundaryUrl, entity.getBoundaryUrl())
                .likeIfPresent(YdbForecastEntity::getBoundaryName, entity.getBoundaryName())
                .eqIfPresent(YdbForecastEntity::getDrawJson, entity.getDrawJson())
                .eqIfPresent(YdbForecastEntity::getMaxlat, entity.getMaxlat())
                .eqIfPresent(YdbForecastEntity::getMaxlng, entity.getMaxlng())
                .eqIfPresent(YdbForecastEntity::getMinlat, entity.getMinlat())
                .eqIfPresent(YdbForecastEntity::getMinlng, entity.getMinlng())
                ;
    }



}
